//
//  PKRoortLeftViewController.m
//  PianKe
//
//  Created by mingtao on 15/9/25.
//  Copyright (c) 2015年 mingtao. All rights reserved.
//

#import "PKRoortLeftViewController.h"

#import "PKRootRightViewController.h"

#import "PKrotView.h"

@interface PKRoortLeftViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)PKRootRightViewController *rootRigVC;

@property(nonatomic,strong)UITableView *mainListTabeview;//主列表

@property(nonatomic,strong)NSArray *dataSourceArray;//提供数据源

@end

@implementation PKRoortLeftViewController

-(NSArray *)dataSourceArray
{
    if (_dataSourceArray ==nil) {
        
        _dataSourceArray = @[@"首页",@"电台",@"分组",@"良品",@"阅读"];
       // _dataSourceArray = [NSArray ]
    }
    
    return _dataSourceArray;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //添加右侧视图控制器的view
    //ARC里面，编译器（LLVM）会自动帮我们添加release代码，添加的时机就是这个对象出作用域的时候，所以我们工程被编译成二进制文件的时候还是有release代码的，只不过我们没有写，看不到而已
    
    _rootRigVC=[[PKRootRightViewController alloc]init];
    
    _rootRigVC.view.backgroundColor = [UIColor orangeColor];
    
   
    
    _mainListTabeview = [[UITableView alloc]initWithFrame:CGRectMake(0, 200, WIHES-40,HHIHEI - 280)];
    
    _mainListTabeview.dataSource = self;
    
    _mainListTabeview.delegate = self;
    
    [_mainListTabeview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    
    //表位去表横杆
    _mainListTabeview.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    
    PKrotView *aa=[[PKrotView alloc]initWithFrame:CGRectMake(0, 0, WIHES-40, HHIHEI-387)];
    
    aa.backgroundColor = [UIColor yellowColor];
    
    [self.view addSubview:aa];
    
    [self.view addSubview:_mainListTabeview];
    
     [self.view addSubview:_rootRigVC.view];
    
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_rootRigVC changeViewWithIndex:indexPath.row];
    

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  self.dataSourceArray.count;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
    
    cell.textLabel.text = self.dataSourceArray[indexPath.row];
    
    return cell;

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
